<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //1.数组的拼接
        //第一种发法
       /*  var arr = [1, 2, 3, 4, 5, 6];
        var sum = '';
        for(var i = 0; i < arr.length; i++){
            sum += arr[i] + '--'
        }
        console.log(sum); */

        //第二种方法
        /* var arr = [1, 2, 3, 4, 5, 6];
        var sum = arr.join('--');
        console.log(sum); */

        //2.数组的翻转
       /*  var arr = [1, 2, 3, 4, 5, 6];
        var sum = [];
        for(var i = arr.length - 1; i >=0 ; i--){
            sum[sum.length] = arr[i];
        }
        console.log(sum); */

        //3.数组的比大小
        /* var arr = [1, 2, 3, 4, 5, 6];
        var max = arr[0];
        for(var i = 0; i < arr.length; i++){
            if(arr[i] > max){
                max = arr[i];
            }
        }
        console.log(max); */

        //4冒泡排列
        var arr = [6, 5, 4, 3, 2, 1];
        for(var i = 0 ; i < arr.length - 1 ; i++){
            for(var j = 0; j < arr.length -1 -i ; j++){
                if(arr[j] > arr[j + 1]){
                    var tem = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tem;
                }
                
            }
        }
        console.log(arr);
    </script>
</body>
</html>